#include "TemplateElement.h"
#include <iostream>

int main()
{
    vector<double> p0 = {-1, -1};
    vector<double> p1 = {0, 1};
    vector<double> p2 = {1, 1};
    vector<double> p3 = {-1, 1};
    Point<2> P0(p0);
    Point<2> P1(p1);
    Point<2> P2(p2);
    Point<2> P3(p3);
    vector<Point<2>> d = {P0, P1, P2, P3};
    Domain<2> *D = new Rectangle2D(d);
    vector<int> seg = {4, 4};
    // 1阶测试
    Mesh<2> *M1 = new Q1Mesh(D, seg);
    M1->distributeDofs();
    M1->setBoundaryIndex();
    Grid<2> g1 = M1->getGrid(3);
    TemplateElement<2> *E1 = new Quadrilateral_1_Element();
    E1->reinit(g1, *M1);
    for (int i = 0; i < 4; i++)
        cout << E1->getGlobalIndex(i) << endl;
    for (int i = 0; i < E1->getBoundaryDofsonGrid().size(); i++)
        cout << E1->getBoundaryDofsonGrid()[i] << endl;
    // 2阶测试
    Mesh<2> *M2 = new Q2Mesh(D, seg);
    M2->distributeDofs();
    M2->setBoundaryIndex();
    Grid<2> g2 = M1->getGrid(4);
    TemplateElement<2> *E2 = new Quadrilateral_2_Element();
    E2->reinit(g2, *M2);
    for (int i = 0; i < 9; i++)
        cout << E2->getGlobalIndex(i) << endl;
    for (int i = 0; i < E2->getBoundaryDofsonGrid().size(); i++)
        cout << E2->getBoundaryDofsonGrid()[i] << endl;
}